package webservice;

import java.util.ArrayList;

import javax.jws.WebService;

import simri.sensor.LeituraSensor;
import simri.sensor.Sensor;
import simri.servidor.negocio.manager.UCManterSensorManager;

@WebService(endpointInterface="webservice.ISIMRI_WS",serviceName="SIMRI_WS")
public class SIMRI_WS implements ISIMRI_WS {

	private UCManterSensorManager sensorManager;
	
	public SIMRI_WS()
	{
		sensorManager = new UCManterSensorManager();
	}
	
	@Override
	public String[][] consultaSn(Sensor pkSensor, int tipo) {
		ArrayList<ArrayList<String>> lista = sensorManager.consultaSn(pkSensor, tipo);
		String [][] ret = new String[lista.size()][];
		for (int i=0; i<lista.size(); i++) {
			ArrayList<String> sublista = lista.get(i);
			ret[i] = new String[sublista.size()];
			for (int j = 0; j < sublista.size(); j++) {
				ret[i][j] = sublista.get(j);
			}
		}
		return ret;
	}

	@Override
	public String[][] consultaAq(LeituraSensor pkLeitura, int tipo) {
		ArrayList<ArrayList<String>> lista = sensorManager.consultaAq(pkLeitura, tipo);
		String [][] ret = new String[lista.size()][];
		for (int i=0; i<lista.size(); i++) {
			ArrayList<String> sublista = lista.get(i);
			ret[i] = new String[sublista.size()];
			for (int j = 0; j < sublista.size(); j++) {
				ret[i][j] = sublista.get(j);
			}
		}
		return ret;
	}
	
	@Override
	public String[][] consultaEvery(){
		ArrayList<ArrayList<String>> lista = sensorManager.consultaEvery();
		String [][] ret = new String[lista.size()][];
		for (int i=0; i<lista.size(); i++) {
			ArrayList<String> sublista = lista.get(i);
			ret[i] = new String[sublista.size()];
			for (int j = 0; j < sublista.size(); j++) {
				ret[i][j] = sublista.get(j);
			}
		}
		return ret;
	}

	@Override
	public void cadSensor(Sensor pkSensor) {
		sensorManager.cadSensor(pkSensor);
	}

	@Override
	public void cadLeitura(LeituraSensor pkLeitura) {
		sensorManager.cadLeitura(pkLeitura);
	}

}
